<template>
  <div class="total-container">
    <div v-if="!!topData" class="top-box">
      <div class="left-container">
        <div class="icon"></div>
        <div class="value">
          <div class="title">{{ topData[0].xm }}</div>
          <div class="bottom-value">
            <span class="num">
              <CountTo
                :startVal="0"
                :endVal="+topData[0].sz"
                :duration="1200"
                separator=""
              ></CountTo>
            </span>
            <span class="unit">{{ topData[0].unit }}</span>
          </div>
        </div>
      </div>
      <div class="right-container">
        <div class="rate-1">
          <div class="arrow"></div>
          <div class="rate-num">{{ topData[1].sz }}{{ topData[1].unit }}</div>
        </div>
        <div class="rate-2">
          <span class="desc">{{ topData[2].xm }}</span>
          <span class="rate-num">{{ topData[2].sz }}{{ topData[2].unit }}</span>
        </div>
      </div>
    </div>
    <!-- <div v-if="!!centerData" class="center-box">
      <div class="left-container">{{ centerData.xm }}</div>
      <div class="right-container">
        <div class="num">
          <CountTo
            :startVal="0"
            :endVal="+centerData.sz"
            :duration="1200"
            separator=""
          ></CountTo>
        </div>
        <div class="unit">{{ centerData.unit }}</div>
      </div>
    </div>
    <div class="chart-container">
      <areaComp :chart-data="chartData"></areaComp>
    </div> -->
  </div>
</template>
<script>
import areaComp from './charts/area.vue'
import CountTo from 'vue-count-to'
import { getLbData, getLyrsnf } from '@/api/cultureTuorism.js'
export default {
  data() {
    return {
      chartData: {
        xAxis: { name: '', data: ['2018', '2019', '2020', '2021', '2022'] },
        yAxis: { name: '单位： 亿人次', data: [] },
        data: [1, 2, 3, 2, 1]
      },
      topData: null,
      centerData: null
    }
  },
  components: {
    areaComp,
    CountTo
  },
  mounted() {
    this.getData()
  },
  methods: {
    async getData() {
      const [res1, res2, res3] = await Promise.all([
        getLbData('旅游人数'),
        getLbData('旅游人数概况'),
        getLyrsnf()
      ])
      this.topData = res1.result
      this.centerData = res2.result[0]
    }
  }
}
</script>
<style lang="scss" scoped>
.total-container {
  display: flex;
  flex-direction: column;
  justify-content: center;
  .top-box {
    width: 409px;
    height: 66px;
    background: url('../../img/left-row3-icon1.png') no-repeat center bottom;
    background-size: 100% 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    .left-container {
      height: 100%;
      display: flex;
      justify-content: center;
      align-items: center;
      margin-bottom: 12px;
      .icon {
        width: 51px;
        height: 48px;
        background: url('../../img/left-row3-icon2.png') no-repeat center center;
        background-size: 100% 100%;
      }
      .value {
        margin-left: 5px;
        .title {
          width: 96px;
          height: 17px;
          font-family: MicrosoftYaHeiUI;
          font-size: 16px;
          color: #ffffff;
          line-height: 16px;
          text-align: left;
          font-style: normal;
          text-transform: none;
          background: url('../../img/left-row3-icon3.png') no-repeat center
            bottom;
          background-size: 93px 12px;
        }
        .bottom-value {
          margin-top: 10px;
          display: flex;
          align-items: center;
          .num {
            font-family: YouSheBiaoTiHei;
            font-size: 24px;
            line-height: 24px;
            color: #16fdf5;
            text-align: right;
            font-style: normal;
            text-transform: none;
          }
          .unit {
            font-family: MicrosoftYaHeiUI;
            font-size: 14px;
            color: #fefefe;
            line-height: 24px;
            text-align: left;
            font-style: normal;
            text-transform: none;
            margin-left: 4px;
          }
        }
      }
    }
    .rate-num {
      font-family: MicrosoftYaHeiUI, MicrosoftYaHeiUI;
      font-weight: bold;
      font-size: 16px;
      color: #fe3d3d;
      line-height: 16px;
      text-align: left;
      font-style: normal;
      text-transform: none;
      margin-left: 4px;
    }
    .right-container {
      height: 100%;
      display: flex;
      flex-direction: column;
      justify-content: start;
      align-items: start;
      padding-left: 60px;
      .rate-1 {
        display: flex;
        justify-content: center;
        align-items: center;
        .arrow {
          width: 10px;
          height: 14px;
          background: url('../../img/left-row3-icon4.png') no-repeat center
            center;
          background-size: 100% 100%;
        }
      }
      .rate-2 {
        margin-top: 14px;
        .desc {
          font-family: MicrosoftYaHeiUI;
          font-size: 14px;
          color: #ffffff;
          line-height: 14px;
          text-align: left;
          font-style: normal;
          text-transform: none;
        }
      }
    }
  }
  .center-box {
    width: 408px;
    height: 47px;
    background: url('../../img/left-row1-icon1.png') no-repeat center center;
    background-size: 100% 100%;
    margin-top: 3px;
    display: flex;
    justify-content: space-between;
    padding: 15px;
    .left-container {
      height: 100%;
      font-family: MicrosoftYaHeiUI;
      font-size: 16px;
      color: #ffffff;
      line-height: 16px;
      text-align: left;
      font-style: normal;
      text-transform: none;
    }
    .right-container {
      height: 100%;
      display: flex;
      justify-content: end;
      align-items: center;
      .num {
        font-family: YouSheBiaoTiHei;
        font-size: 24px;
        color: #16fdf5;
        line-height: 0px;
        text-align: right;
        font-style: normal;
        text-transform: none;
      }
      .unit {
        font-family: MicrosoftYaHeiUI;
        font-size: 14px;
        color: #fefefe;
        line-height: 0px;
        text-align: left;
        font-style: normal;
        text-transform: none;
        margin-left: 4px;
      }
    }
  }
  .chart-container {
    height: 120px;
    margin-top: 10px;
  }
}
</style>
